import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import BookList from "../components/Book_list.vue"
import Me from "../views/Me.vue"
import CookHome from "../views/Cook_home.vue"
import Register from "../views/Register.vue"

import Login from "../views/Login.vue"

import Search from '../views/Seach.vue'
import Add from "../views/Add.vue"
import CookBook from "../views/Cook_book.vue"
import Author from '../views/Author.vue'


Vue.use(VueRouter)


const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    redirect:"/cookHome",
    children:[
      {
        path:'/me',
        component:Me,
      },
      {
        path:'/cookHome',
        component:CookHome,
      },
  ]
  },
  {
    path: '/author',
    component: Author,
  },
  {
    path: '/register',
    component: Register
  },
  {
    path: '/login',
    component: Login
  },{
    path:'/search',
    component:Search,
  },{
    path: '/add',
    component: Add
  },
  {
    path:'/cookBook',
    component:CookBook,
  }

  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]
const originalPush = VueRouter.prototype.push
 
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})



export default router
